package com.hxy.health.platform.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxy.health.platform.dao.BlogMapper;
import com.hxy.health.platform.pojo.Blog;
import com.hxy.health.platform.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceImpl implements BlogService {
    @Autowired
    private BlogMapper blogMapper;
    /**
     * 带有分页查询所有文章信息
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<Blog> getAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Blog> blogs = blogMapper.getAll();
        PageInfo pageInfo = new PageInfo(blogs);
        return pageInfo;
    }

    /**
     * 获取文章详情
     * @param id
     * @return
     */
    @Override
    public Blog getById(Integer id) {
        return blogMapper.selectByPrimaryKey(id);
    }
}
